package com.yzd.netmonitor.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yzd.netmonitor.web.RespBody;
import com.yzd.netmonitor.web.ResponseCode;

@RestController
public class ExceptionController extends BaseController {

	@RequestMapping("/404")
	public RespBody error404() {

		return respWriter.toError(ResponseCode.CODE_404);
	}

	@RequestMapping("/500")
	public RespBody error500(HttpServletRequest request) {

		Throwable e = (Throwable) request.getAttribute("javax.servlet.error.exception");
		return respWriter.toError(ResponseCode.CODE_500, e.toString());
	}

	@RequestMapping("/501")
	public RespBody error501() {

		return respWriter.toError(ResponseCode.CODE_501);
	}

	@RequestMapping("/502")
	public RespBody error502() {

		return respWriter.toError(ResponseCode.CODE_502);
	}
}
